<template>
    <view class="pg">
        <view v-if="'material' in publish">
            <!-- <image v-if="publish.material.type === 1" :src="publish.material.filePath" mode="heightFix" class="w-750 h-450"></image> -->
            <wd-img v-if="publish.material.type === 1" :src="publish.material.filePath" :enable-preview="true" mode="aspectFit" width="750rpx" height="450rpx" />
            <video v-else id="myVideo" :src="publish.material.filePath" @error="videoErrorCallback" loop autoplay controls enable-play-gesture class="w-750"></video>
        </view>
        <wd-cell-group border v-if="'material' in publish">
            <wd-input readonly size="large" label="名称" v-model="publish.material.name" label-width="16%" />
            <wd-input readonly size="large" label="场地" v-model="publish.regionName" label-width="16%" />
            <wd-input readonly size="large" label="播放时间" v-model="publish.duration" label-width="16%" />
            <wd-input readonly size="large" label="播放位置" v-model="publish.position" label-width="16%" />
            <wd-input readonly size="large" label="创建时间" v-model="publish.createTime" label-width="16%" />
            <wd-input readonly size="large" label="生效时间" v-model="publish.effectTime" label-width="16%" />
            <wd-input readonly size="large" label="截止时间" v-model="publish.cutoffTime" label-width="16%" />
            <wd-input readonly size="large" label="审核时间" v-model="publish.auditTime" label-width="16%" />
            <wd-cell size="large">
                <template #title>
                    <view class="fl-ro-cen gap-24">
                        <wd-text text="审核情况" color="#333"></wd-text>
                        <wd-text
                            :text="publish.state === 0 ? '未通过' : publish.state === 1 ? '审核中' : '已通过'"
                            :type="publish.state === 0 ? 'error' : publish.state === 1 ? 'warning' : 'success'"
                        ></wd-text>
                    </view>
                </template>
            </wd-cell>
        </wd-cell-group>
    </view>
</template>

<script setup>
    import { onLoad } from '@dcloudio/uni-app';
    import { api_advertiseApply_dtoList } from '@/api/advertiseApply.js';
    import { api_region_list } from '@/api/region.js';
    import { ref } from 'vue';

    const publish = ref({});

    onLoad(async (e) => {
        try {
            let queryMap = {
                eq: {},
                in: {},
                like: {},
                ge: {},
                le: {},
                order: {
                    create_time: 'desc'
                }
            };
            //广告查询
            let res1 = await api_advertiseApply_dtoList({ pageCut: false, queryMap: { ...queryMap, eq: { id: e.id } } });
            publish.value = {
                ...res1.data[0],
                duration: `${res1.data[0].duration}秒`,
                position: res1.data[0].position === 1 ? '上半屏' : res1.data[0].position === 2 ? '下半屏' : '全屏',
                auditTime: res1.data[0].auditTime === null ? '审核中' : res1.data[0].auditTime
            };

            //位置查询
            let res2 = await api_region_list({ pageCut: false, queryMap: { ...queryMap, eq: { id: publish.value.rid } } });
            publish.value = { ...publish.value, regionName: res2.data[0].name };
        } catch (error) {
            uni.showToast({
                title: '出错了T^T',
                icon: 'none'
            });
        }
    });
</script>

<style lang="scss" scoped></style>
